<template>
  <el-dialog title="详细信息" :visible.sync="accountsVisable" append-to-body>
    <el-table :data="tableData" style="width: 100%" border show-overflow-tooltip>
      <el-table-column prop="sysOrderNum" label="单号" width="200" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-if="scope.row.payType == 0 || scope.row.payType == 5 || scope.row.payType == 3 || scope.row.payType == 8">{{scope.row.ruSysNo}}</span>
          <span v-if="scope.row.payType == 4 || scope.row.payType == 2">{{scope.row.sysNo}}</span>
          <span v-if="scope.row.payType == 7 || scope.row.payType == 6">{{scope.row.sysOrderNum}}</span>
          <!-- <span v-else>--</span> -->
        </template>
      </el-table-column>
      <el-table-column prop="payType" label="项目名称" width="150">
        <template slot-scope="scope">
          <span v-if="payTypeMap[scope.row.payType][0] == '红冲'">
            {{scope.row.agreementId ? '协议单位红冲' : '客房红冲'}}
          </span>
          <span v-else-if="payTypeMap[scope.row.payType][0] == '优惠金额'">
            {{scope.row.posid ? 'POS优惠' : '结账优惠'}}
          </span>
          <span v-else>{{payTypeMap[scope.row.payType][0]}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="banks" label="房间号" width="150">
        <template slot-scope="scope">
          <span v-if="scope.row.banks">{{scope.row.banks}}</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
      <el-table-column prop="consumeInfo" label="付款方式" width="150">
        <template slot-scope="scope">
          <span v-if="scope.row.consumeInfo">{{scope.row.consumeInfo}}</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
      <el-table-column prop="payPrice" label="金额" width="150">
        <template slot-scope="scope">
          <el-tag :type="payTypeMap[scope.row.payType][1]">
            {{payTypeMap[scope.row.payType][2]+scope.row.payPrice}}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="creatTime" label="发生时间" width="180">
      </el-table-column>
      <el-table-column prop="turnPeopleId" label="转账账号" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-if="scope.row.turnPeopleId">{{scope.row.turnPeopleId}}</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
      <el-table-column prop="remarks" label="备注">
        <template slot-scope="scope">
          <span v-if="scope.row.remarks">{{scope.row.remarks}}</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
      <el-table-column prop="banksNumber" label="操作员" width="200">
        <template slot-scope="scope">
          <span v-if="scope.row.banksNumber">{{scope.row.banksNumber}}</span>
          <span v-else>--</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
      :page-sizes="[5,10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
  </el-dialog>

</template>

<script>
  export default {
    data() {
      return {
        accountsVisable: false,
        tableData: [],
        payTypeMap: {
          0: ['预收款账', 'success', '', 'ruSysNo'],
          1: ['信用卡授权', 'success', '', 'ruSysNo'],
          2: ['消费', 'success', '', 'ruSysNo'],
          4: ['房费', 'success', '', 'ruSysNo'],
          5: ['预收退款', 'danger', '-', 'refundNo'],
          6: ['结账收款', 'success', '', 'ruSysNo'],
          7: ['结账退款', 'danger', '-', 'refundNo'],
          3: ['押金收款', 'success', '', 'ruSysNo'],
          8: ['押金退款', 'danger', '-', 'refundNo'],
          9: ['红冲', 'danger', '-', 'refundNo'],
          13: ['优惠金额', 'danger', '-', 'refundNo']
        },
        totalPage: 0,
        pageIndex: 1,
        pageSize: 5,
        type: '',
        nowType: '',
        startTime: '',
        endTime: ''
      }
    },
    methods: {
      init(type, nowType, startTime, endTime) {
        this.accountsVisable = true;
        this.tableData = [];
        this.type = type;
        this.nowType = nowType;
        this.startTime = startTime;
        this.endTime = endTime;
        this.pageIndex = 1;
        this.getData(type, nowType, startTime, endTime);
      },

      getData(type, nowType, startTime, endTime) {
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomcheckinaccounting/getByTypeAndTimeWithShiftWork'),
          method: 'get',
          params: this.$http.adornParams({
            page: this.pageIndex,
            limit: this.pageSize,
            payType: this.type,
            nowType: this.nowType,
            startTime: this.startTime,
            endTime: this.endTime
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            console.log(data)
            this.tableData = data.page.records
            this.totalPage = data.page.total;
          } else {

          }
        })
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val;
        this.pageIndex = 1;
        this.getData();
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val;
        this.getData();
      },
    }
  }
</script>
